#import "ChatMessageEventListener.h"

@implementation ChatMessageEventListener

- (id) initWithEmitter:(RCTEventEmitter *)emitter{
  if ((self = [super init])) {
    _emitter = emitter;
  }
  return self;
}

- (void) onRecieveMessage:(NSString *)fingerPrintOfProtocal 
               withUserId:(NSString *)dwUserid 
               andContent:(NSString *)dataContent 
                 andTypeu:(int)typeu{
  [_emitter sendEventWithName: @"onReceiveMessage" 
                         body: @{ 
                           @"fp": fingerPrintOfProtocal, 
                           @"fromId": dwUserid,
                           @"dataContent": dataContent,
                           @"typeU": [NSNumber numberWithInt: typeu]
                         }
  ];
}

- (void) onErrorResponse:(int)errorCode 
            withErrorMsg:(NSString *)errorMsg{
  [_emitter sendEventWithName: @"onErrorResponse" 
                         body: @{ 
                           @"code": [NSNumber numberWithInt: errorCode], 
                           @"msg": errorMsg 
                         }
  ];
}

@end
